package test3_25.demo15;

/*
定义一个方法，求出字符串中有多少种字符，以及每个字符的个数
static void printCharInfo(String str)
例如有字符串 str="apple is a apple.";
   结果应该是
	a:3 p:4 l:2 e:2  :3 i:1 s:1 .:1
 */
public class Homework14_17 {

    public static void charNum(String s) {
        int l = s.length();
        while (l > 0) {
            String first = s.charAt(0) + "";
            s = s.replace(first, "");
            int num = l - s.length();
            System.out.println(first + ":" + num);
            l = s.length();
        }
    }

    public static void main(String[] args) {
        Homework14_17.charNum("apple is a apple.");
    }
}
